<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Product extends CI_Controller {
    
    /**
     * Index action 
     * @author tien.nguyen
     */
	public function index($cateId = null, $page = 1){	
        //instance model
        $this->load->model('Products', '', true);
        
        $page = empty($page) ? 0 : $page;
        //load data by model 
        $data['Products'] = $this->Products->getListProduct($cateId, $page);
        $data['CateId'] = $cateId;
		$this->load->view('product/index', $data);
	}
    
    /**
     * Show product 2
     **/
    public function index2($cateId = null, $page = 1){	
        //instance model
        $this->load->model('Products', '', true);
        
        $page = empty($page) ? 0 : $page;
        //load data by model 
        $data['Products'] = $this->Products->getListProduct($cateId, $page);
        $data['CateId'] = $cateId;
		$this->load->view('product/index', $data);
	}
    
    /**
     * get detail
     * @author tien.nguyen
     */
    public function detail($cateId, $productId){
        //instance model
        $this->load->model('Products', '', true);
        $this->load->model('Awards', '', true);
        $this->load->model('Pictures', '', true);
        
        $data['Product'] = $this->Products->getProduct($productId);
        $data['Awards'] = $this->Awards->getAwardProductDetail($productId);
        $data['Pictures'] = $this->Pictures->getPictureProductDetail($productId);
        $data['CateId'] = $cateId;
		$this->load->view('product/detail', $data);
    }
    
    /**
     * Download product 
     * @author tien.nguyen
     */
    public function download($productId){
        $this->load->model('Products', '', true);
        
        $data['Product'] = $this->Products->getProduct($productId);
        
        $this->load->view('product/download', $data); 
    }
}